#ifndef __tenacitas_distributed__call__h__
#define __tenacitas_distributed__call__h__


// =============================================================================
/**
   @file 
   File description
*/


// =============================================================================
//                                 C++ Headers

#include <time.h>

// =============================================================================
//                                 3rds Headers


// =============================================================================
//                                 Our Headers


// =============================================================================
//                                 Namespaces
using namespace std;


// =============================================================================
//                                 Macro Contants

/**
 */


// =============================================================================
//                                 Macro Commands

/**
 */


/**
   namespace of the organization
*/
namespace tenacitas {
    /**
       namespace for the project
    */
    namespace distributed {

        // =====================================================================
        //                             Typedefs

        /**
         */


        // =====================================================================
        //                             Pre-Declarations


        // =====================================================================
        //                             Attributes

        /**
         */


        // =====================================================================
        //                             Functions

        /**
         */


        // =====================================================================
        //                             Classes

        /** A call made from a customer to a call center
           
           -----------------------------------------------------------------
           @tparam t_address is the address where a customer should call to, in
           order to reach the call center 

           @nosubgrouping 
        */
        template <typename t_address>
        class call {

            // -----------------------------------------------------------------
            //    call - Friends

        public:

            // -----------------------------------------------------------------
            //    call - Public Internal Types

            typedef t_address address_type;
            
            

            // -----------------------------------------------------------------
            //    call - Public Constructors

            /** Constructor

                Defines the calling address
            */
            call( const address_type & p_calling_address );

            /** Copy constructor */
            call ( const call & p_call );

            /**
               Destructor
            */
            ~call ( ) ;

            // -----------------------------------------------------------------
            //    call - Public Accessors
            
            /** Defines the time that the call was received by a call center */
            void received( time_t p_time );

            /** Defines the time that the call started to be handled
                by an agent */
            void answered( time_t p_time );

            /** Defines the time that the call was put on hold */
            void on_hold( time_t p_time );
            
            
            // -----------------------------------------------------------------
            //    call - Public Helpers
            

            // -----------------------------------------------------------------
            //    call - Public Processors
            

            // -----------------------------------------------------------------
            //    call - Public Operators

            /** assignment */
            call & operator= ( const call & p_call );
            

            // -----------------------------------------------------------------
            //    call - Public Attributes
            

        protected:

            // -----------------------------------------------------------------
            //    call - Protected Internal Types
            

            // -----------------------------------------------------------------
            //    call - Protected Constructors
            

            // -----------------------------------------------------------------
            //    call - Protected Accessors
            

            // -----------------------------------------------------------------
            //    call - Protected Helpers
            

            // -----------------------------------------------------------------
            //    call - Protected Processors
            

            // -----------------------------------------------------------------
            //    call - Protected Operators
            

            // -----------------------------------------------------------------
            //    call - Protected Attributes
            

        private:

            // -----------------------------------------------------------------
            //    call - Private Internal Types
            

            // -----------------------------------------------------------------
            //    call - Private Constructors
            

            // -----------------------------------------------------------------
            //    call - Private Accessors
            

            // -----------------------------------------------------------------
            //    call - Private Helpers
            

            // -----------------------------------------------------------------
            //    call - Private Processors
            

            // -----------------------------------------------------------------
            //    call - Private Operators
            

            // -----------------------------------------------------------------
            //    call - Private Attributes

            /** calling address */
            address_type m_calling_address;

            /** time the call was received in the call center */
            time_t m_time_received;

            /** time the call was actually answered by an agent */
            time_t m_time_answered;
            
            /** time that the call was put on hold */
            time_t m_time_on_hold;
        };

    }
}

// =============================================================================
//                     I M P L E M E N T A T I O N
// =============================================================================

using namespace tenacitas::distributed;

// -----------------------------------------------------------------------------
template <typename t_address>
call<t_address>::
call( const t_address & p_calling_address )
    : m_calling_address( p_calling_address ),
      m_time_received( 0 ),
      m_time_answered( 0 ),
      m_time_on_hold( 0 ) {}

// -----------------------------------------------------------------------------
template <typename t_address>
call<t_address>::
~call( ) {}

// -----------------------------------------------------------------------------
template <typename t_address>
call<t_address>::
call ( const call & p_call )
    : m_calling_address( p_call.m_calling_address ),
      m_time_received( p_call.m_time_received ),
      m_time_answered( p_call.m_time_answered ),
      m_time_on_hold( p_call.m_time_on_hold ) {}

// -----------------------------------------------------------------------------
template <typename t_address>
call<t_address> &
call<t_address>::
operator= ( const call<t_address> & p_call ) {
    if ( this != &p_call ) {
        m_calling_address = p_call.m_calling_address;
        m_time_received = p_call.m_time_received;
        m_time_answered = p_call.m_time_answered;
        m_time_on_hold = p_call.m_time_on_hold;
    }
    return *this;
}

      


#endif
